package com.hex.ds.hdtp.core.inf.data.transfer.repository.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hex.ds.hdtp.core.inf.common.page.Page;
import com.hex.ds.hdtp.core.inf.common.page.converter.IPageAndMyBatisPlusPageConverter;
import com.hex.ds.hdtp.core.inf.data.transfer.mapper.IDataTransferLogMapper;
import com.hex.ds.hdtp.core.inf.data.transfer.po.DataTransferLogPo;
import com.hex.ds.hdtp.core.inf.data.transfer.repository.IDataTransferLogRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Package: com.hex.ds.hdtp.core.inf.data.transfer.repository.impl
 * @ClassName DataTransferLogRepository
 * @Description: 数据迁移记录-数据服务接口实现
 * @Author: wz.li
 * @Date 2023/8/18 13:41
 * @Version v2.0.2
 **/
@Component
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class DataTransferLogRepository implements IDataTransferLogRepository {

    private final IDataTransferLogMapper dataTransferLogMapper;

    private final IPageAndMyBatisPlusPageConverter pageConverter;

    /*
     * @Method: queryListByPage <br>
     * @Param: [dataTransferLogPo, toPage] <br>
     * @Return: com.hex.ds.hdtp.core.inf.common.page.Page<com.hex.ds.hdtp.core.inf.data.transfer.po.DataTransferLogPo> <br>
     * @Description：分页查询<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/18 13:42 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Page<DataTransferLogPo> queryListByPage(DataTransferLogPo dataTransferLogPo, Page toPage) {
        final IPage tmpPageReslt = dataTransferLogMapper.queryListByPage(
                pageConverter.toMyBatisPlusPage(toPage)
                , dataTransferLogPo
        );
        final List list = tmpPageReslt.getRecords();
        final Page pageResult = pageConverter.toPage(tmpPageReslt);
        return pageResult.setData(list);
    }

    /*
     * @Method: queryById <br>
     * @Param: [pkId] <br>
     * @Return: com.hex.ds.hdtp.core.inf.data.transfer.po.DataTransferLogPo <br>
     * @Description：根据主键查询 <br>
     * @Author： wz.li<br>
     * @Date： 2023/8/18 13:42 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public DataTransferLogPo queryById(String pkId) {
        return dataTransferLogMapper.selectById(pkId);
    }

    /*
     * @Method: add <br>
     * @Param: [dataTransferLogPo] <br>
     * @Return: java.lang.Integer <br>
     * @Description：新增<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/18 13:43 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Integer add(DataTransferLogPo dataTransferLogPo) {
        return dataTransferLogMapper.insert(dataTransferLogPo);
    }

    /*
     * @Method: modifyById <br>
     * @Param: [dataTransferLogPo] <br>
     * @Return: java.lang.Integer <br>
     * @Description：根据主键更新<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/18 13:43 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Integer modifyById(DataTransferLogPo dataTransferLogPo) {
        return dataTransferLogMapper.updateById(dataTransferLogPo);
    }

    /*
     * @Method: removeById <br>
     * @Param: [pkId] <br>
     * @Return: java.lang.Integer <br>
     * @Description：根据主键删除<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/18 13:43 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Integer removeById(String pkId) {
        return dataTransferLogMapper.deleteById(pkId);
    }
}
